<template>
  <div class="app-container">
    <el-descriptions :column="3" class="margin-top" border>

      <el-descriptions-item>
        <template slot="label">
          <i class="el-icon-user"/>
          单位名称
        </template>
        {{ unit.name }}
      </el-descriptions-item>

      <el-descriptions-item>
        <template slot="label">
          <i class="el-icon-user"/>
          职位名称
        </template>
        {{ job.jobName }}
      </el-descriptions-item>

      <el-descriptions-item>
        <template slot="label">
          <i class="el-icon-user"/>
          招考人数
        </template>
        {{ job.capacity }}
      </el-descriptions-item>

      <el-descriptions-item>
        <template slot="label">
          <i class="el-icon-user"/>
          招考人数
        </template>
        {{ job.surplus }}
      </el-descriptions-item>

      <el-descriptions-item>
        <template slot="label">
          <i class="el-icon-user"/>
          年龄范围
        </template>
        {{ job.minAge + ' ~ ' + job.maxAge }}
      </el-descriptions-item>

      <el-descriptions-item>
        <template slot="label">
          <i class="el-icon-user"/>
          性别要求
        </template>
        {{ get_sex(job.sex) }}
      </el-descriptions-item>

      <el-descriptions-item>
        <template slot="label">
          <i class="el-icon-user"/>
          民族要求
        </template>
        {{ job.nation }}
      </el-descriptions-item>

      <el-descriptions-item>
        <template slot="label">
          <i class="el-icon-user"/>
          政治面貌要求
        </template>
        {{ get_political(job.political) }}
      </el-descriptions-item>

      <el-descriptions-item>
        <template slot="label">
          <i class="el-icon-user"/>
          学历要求
        </template>
        {{ get_education(job.education) }}
      </el-descriptions-item>

      <el-descriptions-item>
        <template slot="label">
          <i class="el-icon-user"/>
          专业要求
        </template>
        {{ job.major }}
      </el-descriptions-item>

      <el-descriptions-item>
        <template slot="label">
          <i class="el-icon-user"/>
          试卷类型
        </template>
        {{ job.testType }}
      </el-descriptions-item>

      <el-descriptions-item>
        <template slot="label">
          <i class="el-icon-user"/>
          考试名称
        </template>
        {{ job.testName }}
      </el-descriptions-item>

      <el-descriptions-item>
        <template slot="label">
          <i class="el-icon-user"/>
          考试地点
        </template>
        {{ job.testLocation }}
      </el-descriptions-item>

      <el-descriptions-item>
        <template slot="label">
          <i class="el-icon-user"/>
          备注
        </template>
        {{ job.remarks }}
      </el-descriptions-item>

      <el-descriptions-item>
        <template slot="label">
          <i class="el-icon-user"/>
          考试费用
        </template>
        {{ '￥' + job.price }}
      </el-descriptions-item>

      <el-descriptions-item>
        <template slot="label">
          <i class="el-icon-user"/>
          时间范围
        </template>
        {{ job.beginTime + ' ~ ' + job.endTime }}
      </el-descriptions-item>

      <el-descriptions-item>
        <template slot="label">
          <i class="el-icon-user"/>
          查看应聘情况
        </template>
        <router-link :to="'/job/register/' + job.id">
          <el-button type="primary" size="mini" icon="el-icon-edit">点此前往</el-button>
        </router-link>
      </el-descriptions-item>

    </el-descriptions>
  </div>
</template>
<script>
import job from '@/api/hr/job'
export default {
  data() {
    return {
      unitName: '',
      job: {},
      unit: {}
    }
  },
  created() {
    this.init()
  },
  methods: {
    init() {
      if (this.$route.params && this.$route.params.id) {
        const id = this.$route.params.id
        this.get_job(id)
      } else {
        this.job = {}
        this.unit = {}
      }
    },
    get_job(id) {
      job.get_job(id)
        .then(response => {
          this.job = response.data.job
          this.unit = response.data.unit
        })
    },
    get_sex(sex) {
      switch (sex) {
        case 0:
          return '男'
        case 1:
          return '女'
        case -1:
          return '不限'
      }
    },
    get_political(political) {
      switch (political) {
        case 0:
          return '党员'
        case 1:
          return '共青团员'
        case 2:
          return '群众'
      }
    },
    get_education(education) {
      switch (education) {
        case 0:
          return '小学'
        case 1:
          return '初中'
        case 2:
          return '高中'
        case 3:
          return '中专'
        case 4:
          return '本科'
        case 5:
          return '大专'
        case 6:
          return '硕士研究生'
        case 7:
          return '博士研究生'
      }
    }
  }
}
</script>
